<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
        <title>排行榜</title>
        <link rel="stylesheet" href="/cdn/weui.min.css">
        <link rel="stylesheet" href="/cdn/jquery-weui.min.css">
        <script src="/cdn/jquery.min.10.js"></script>
        <script src="/cdn/jquery-weui.min.js"></script>
    </head>
    <body>
        <div class="top">
        <a href="javascript:;" onclick="window.history.back(-1)" style="float: left;color: #fff;"><&nbsp;返回</a>
            <h2>排行榜</h2>
            <div class="desc">
                <p><span>排行指标：</span>{if $invitation->top_type == 1}添加新客户{else}邀请客户加入群聊{/if}</p>
                <p><span>开始时间：</span>{$invitation->start_time}</p>
                <p><span>结束时间：</span>{$invitation->end_time}</p>
            </div>
            <div class="leftTime">
                <p>活动倒计时</p>
                <div class="timeBox" id="timebox">
                    <span id="days">0</span><b>天</b>
                    <span id="hours">00</span><b>时</b>
                    <span id="minutes">00</span><b>分</b>
                    <span id="seconds">00</span><b>秒</b>
                </div>
            </div>
            <div class="top3">
                {if $invitation->data[2]}
                <div class="left box">
                    <img src="{$invitation->data[2]['avatar']}" />
                    <span>{$invitation->data[2]['name']}</span>
                    <div class="count">
                         <span>邀请人数</span>
                         <b>{$invitation->data[2]['size']}</b>
                    </div>
                </div>
                {/if}
                {if $invitation->data[0]}
                <div class="center box">
                    <img src="{$invitation->data[0]['avatar']}" />
                    <span>{$invitation->data[0]['name']}</span>
                    <div class="count">
                         <span>邀请人数</span>
                         <b>{$invitation->data[0]['size']}</b>
                    </div>
                </div>
                {/if}
                {if $invitation->data[1]}
                <div class="right box">
                    <img src="{$invitation->data[1]['avatar']}" />
                    <span>{$invitation->data[1]['name']}</span>
                    <div class="count">
                         <span>邀请人数</span>
                         <b>{$invitation->data[1]['size']}</b>
                    </div>
                </div>
                {/if}
            </div>
            {if count($invitation->data) > 3}
                <ul>
                    {loop $invitation->data as $key=>$data}
                        {if $key >2}
                            <li>
                                <i class="pm">{$key+1}</i>
                                <img src="{$data['avatar']}" />
                                <h5>{$data['name']}</h5>
                                <div class="count">
                                    <span>邀请人数</span>
                                    <b>{$data['size']}</b>
                                </div>
                            </li> 
                        {/if}
                    {/loop}
                </ul>
            {/if}
        </div>
    </body>
    <style>
        .top{
            text-align: center;
            background-color: #237cfe;
            min-height: 100vh;
            padding: 15px;
        }
        .top h2{
            margin-bottom: 20px;
            color: #ffffff;
        }
        .top .desc{
            text-align: left;
            color: #fff;
            padding: 20px;
            border: 1px solid #619bef;
            border-radius: 5px;
            margin-bottom: 20px;
            font-size: 14px;
        }
        .top .desc h6{
            margin-bottom: 10px;
        }
        .leftTime{
            color: #fff;
            font-size: 14px;
            margin-bottom: 20px;
        }
        .leftTime p{
            margin-bottom: 20px;
        }
        .timeBox span{
            display: inline-block;
            background-color: #125ac3;
            width: 30px;
            height: 30px;
            line-height: 30px;
        }
        .timeBox b{
            padding:0 10px;
        }
        .top .top3{
            font-size: 0;
            margin-bottom: 20px;
        }
        .top .top3 .box{
            background-color: #ffffff;
            font-size: 14px;
            padding:10px;
            border-radius: 3px;
            color: #333;
            position: relative;
        }
        .top .top3 .box span{
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            display: block;
        }
        .top .top3 .box img{
            max-width: 100%;
            border-radius: 50%;
            position: relative;
            z-index: 0;
        }
        .top .top3 .left{
            width: calc(27% - 30px);
            display: inline-block;
        }
        .top .top3 .left:before{
            content: '';
            display: block;
            width: 24px;
            height: 24px;
            background-image: url(/images/p3.png);
            background-repeat: no-repeat;
            background-position: 0 0;
            background-size: 100%;
            position: absolute;
            left: 3px;
            top: 3px;
        }
        .top .top3 .center{
            width: calc(38% - 20px);
            display: inline-block;
            margin:0 10px;
        }
        .top .top3 .center:before{
            content:'';
            display: block;
            width: 36px;
            height: 36px;
            background-image: url('/images/p1.png');
            background-repeat: no-repeat;
            background-position: 0 0;
            background-size: 36px;
            position: absolute;
            left: 2px;
            top: 2px;
        }
        .top .top3 .right{
            width: calc(35% - 30px);
            display: inline-block;
        }
        .top .top3 .right:before{
            content:'';
            display: block;
            width: 28px;
            height: 28px;
            background-image: url('/images/p2.png');
            background-repeat: no-repeat;
            background-position: 0 0;
            background-size: 28px;
            position: absolute;
            top: 5px;
            left: 5px;
        }
        .top .top3 .box .count b,
        .top .top3 .box .count span{
            display: block;
        }
        .top .top3 .box .count b{
            color: #ff8080;
        }
        .top .top3 .box .count span{
            font-size: 12px;
            color: #999999;
        }
        ul,li{
            list-style: none;
            position: relative;
            padding: 15px 0;
            border-bottom: 1px solid #f2f2f2;
        }
        ul{
            background-color: #fff;
            border-radius: 5px;
            padding: 15px;
            text-align: left;
        }
        li img,
        li .pm,
        li h5,
        li .count{
            display: inline-block;
            vertical-align: middle;
        }
        li .pm{
            display: inline-block;
            width: 34px;
            height: 34px;
            text-align: center;
            line-height: 34px;
            font-weight: bold;
        }
        li img{
            max-width: 48px;
            border-radius: 50%;
            margin: 0;
        }
        li h5{
            font-weight: normal;
            margin-left: 15px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            display: inline-block;
            max-width: 100px;
        }
        li .count{
            position: absolute;
            right: 0;
        }
        li .count b,
        li .count span{
            display: block;
            text-align: center;
        }
        li .count span{
            font-size: 12px;
            color: #999999;
        }
    </style>
    <script>
        let timer = setInterval("leftTimer('{$invitation->end_time}')",1000);
        function leftTimer(date){ 
            var leftTime = (new Date(date)).getTime() - (new Date()); //计算剩余的毫秒数 
            if(leftTime<=0){
                window.clearTimeout(timer);
                document.getElementById("timebox").innerHTML = '<b style="color: #FF0000;">活动已结束</b>';
            }
            var days = parseInt(leftTime / 1000 / 60 / 60 / 24 , 10); //计算剩余的天数 
            var hours = parseInt(leftTime / 1000 / 60 / 60 % 24 , 10); //计算剩余的小时 
            var minutes = parseInt(leftTime / 1000 / 60 % 60, 10);//计算剩余的分钟 
            var seconds = parseInt(leftTime / 1000 % 60, 10);//计算剩余的秒数 
            days = checkTime(days); 
            hours = checkTime(hours); 
            minutes = checkTime(minutes); 
            seconds = checkTime(seconds); 
            document.getElementById("days").innerHTML = days; 
            document.getElementById("hours").innerHTML = hours; 
            document.getElementById("minutes").innerHTML = minutes; 
            document.getElementById("seconds").innerHTML = seconds; 
        } 
        function checkTime(i){
            if(i<10) { i = "0" + i; } 
            return i; 
        } 
    </script>
</html>
